<?php


namespace App\Http\Controllers\Admin;


use App\Http\Controllers\Admin\Traits\AdminTrait;
use App\Models\Admin\CompanyType;
use Illuminate\Validation\Rule;

class CompanyTypeController extends AdminController
{
    use AdminTrait;

    protected $model;
    protected $unique_id = '';
    public function __construct(CompanyType $model)
    {
        parent::__construct();
        $this->model = $model;
    }
    /**
     * 定义验证规则
     * @var []
     */
    protected $validate_rule = [
    ];

    /**
     * 定特殊的验证规则
     */
    protected function rules()
    {
        return [
            'name'     => [
                'required',
                Rule::unique('company_type')->ignore($this->unique_id),
            ],
        ];
    }

    protected $err_msg = [
        'name.required'         => '名称不能为空',
        'name.unique'         => '名称已存在',
    ];

    protected function search($request){
        return $this->model->where([]);
    }

    protected function setRequestField($arr,$type=false){
        //过滤字段
        if(isset($arr['_token'])) unset($arr['_token']);
        if (isset($arr['sign'])) unset($arr['sign']);
        if (isset($arr['timeStamp'])) unset($arr['timeStamp']);
        return $arr;
    }



}
